package com.zzyl.nursing.controller.member;

import com.zzyl.common.core.controller.BaseController;
import com.zzyl.common.core.domain.AjaxResult;
import com.zzyl.nursing.dto.BindElderDto;
import com.zzyl.nursing.dto.DeviceDto;
import com.zzyl.nursing.dto.QueryIoTDataDto;
import com.zzyl.nursing.service.MemberUserService;
import com.zzyl.nursing.vo.DataPointVO;
import com.zzyl.nursing.vo.MyElderListVo;
import com.zzyl.nursing.vo.MyElderVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 *
 * @Author xiqi
 */
@RestController
@RequestMapping("/member/user")
public class MemberUserController extends BaseController {
    @Autowired
    private MemberUserService memberUserService;
    /**
     * 客户绑定老人,将老人的基本信息保存到老人与家属表的中间表
     */
    @PostMapping("/add")
    public AjaxResult bindElder( @RequestBody BindElderDto dto) {
        memberUserService.bindElder(dto);
        return AjaxResult.success();
    }
    /**
     * 查询自己的老人列表
     */
    @GetMapping("/my")
    public AjaxResult selectMyElder() {
        List<MyElderVo> list = memberUserService.selectMyElder();
        return AjaxResult.success(list);
    }
    /**
     * 查询老人列表
     * @return
     */
    @GetMapping("/list-by-page")
    public AjaxResult selectElderList(){
        List <MyElderListVo> list = memberUserService.selectElderList();
        return AjaxResult.success(list);
    }
    /**
     * 查询健康数据
     */
    @PostMapping("/QueryDevicePropertyStatus")
    public AjaxResult QueryDevicePropertyStatus(@RequestBody DeviceDto dto) {
        Map<String,Object> map = memberUserService.QueryDevicePropertyStatus(dto);
        return AjaxResult.success(map);
    }

    /**
     * 按天统计查询指标数据
     * @param dto
     * @return
     */
    @GetMapping("/queryDeviceDataListByDay")
    public AjaxResult QueryDeviceDataListByDay(QueryIoTDataDto dto) {
          List<DataPointVO> list =  memberUserService.QueryDeviceDataListByDay(dto);
        return AjaxResult.success(list);
    }
    /**
     * 按周统计查询指标数据
     */
    @GetMapping("/queryDeviceDataListByWeek")
    public AjaxResult QueryDeviceDataListByWeek(QueryIoTDataDto dto) {
        List<DataPointVO> list =  memberUserService.QueryDeviceDataListByWeek(dto);
        return AjaxResult.success(list);
    }

}
